package com.gthncz.hello.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.gthncz.hello.beans.User;
import com.gthncz.hello.dto.UserLoginParam;
import com.gthncz.hello.mapper.UserMapper;

@Service
public class UserAdminService {
	
	@Autowired
	private UserMapper userMapper;
	
	/**
	 * 管理员登录服务
	 * 主要业务逻辑是比较数据库中的账户
	 * @param userLoginParam
	 * @return
	 */
	public User login(UserLoginParam userLoginParam) {
		System.out.println(userLoginParam.toString());
		User user = userMapper.findByName(userLoginParam.getUsername());
		System.out.println(user == null ? "true" : user.toString());
		if(user == null || !userLoginParam.getPassword().equals(userLoginParam.getPassword())) {
			return null;
		} else {
			return user;
		}
	}
	

}
